From 7cca11754fb68f1f35468092442d7b1485d2633e Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 3 Mar 2006 10:53:58 +0100 Subject: [PATCH] Fix up some issues I found when porting PPC to the new common gdb stub code: - cosmetic changes in the messages printed - 'flags' must always be unsigned long. - explicitly calling initialize_gdb() is not difficult. For x86 and ia64 I placed this call immediately before do_initcalls(), since that's where it's being called from now so we know it's safe. Architecture people can move it earlier as appropriate. - I don't understand all these ASSERT(!local_irq_is_enabled()) statements, sometimes bracketing a single call like receive_command(). How exactly would receive_command() manage to re-enable irqs? Also, a failing ASSERT would just call into the stub again anways... - initialize_gdb() was overcomplicated. serial_parse_handle() already handles the parsing for us, and there's no need to panic there. Signed-off-by: Hollis Blanchard --- xen/arch/ia64/xen/xensetup.c | 4 +++- xen/arch/x86/setup.c | 3 +++ xen/common/gdbstub.c | 34 +++++++--------------------------- xen/include/xen/gdbstub.h | 10 ++++++++++ 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/xen/arch/ia64/xen/xensetup.c b/xen/arch/ia64/xen/xensetup.c index 8b6faeed26..38784f77df 100644 --- a/xen/arch/ia64/xen/xensetup.c +++ b/xen/arch/ia64/xen/xensetup.c @@ -12,7 +12,7 @@ #include #include #include -//#include +#include #include #include #include @@ -360,6 +360,8 @@ printk("About to call __cpu_up(%d)\n",i); smp_cpus_done(max_cpus); #endif + initialise_gdb(); /* could be moved earlier */ + do_initcalls(); printk("About to call sort_main_extable()\n"); sort_main_extable(); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ae73fe6ca9..b5b0fd68e0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -479,6 +480,8 @@ void __init __start_xen(multiboot_info_t *mbi) printk("Brought up %ld CPUs\n", (long)num_online_cpus()); smp_cpus_done(max_cpus); + initialise_gdb(); /* could be moved earlier */ + do_initcalls(); schedulers_start(); diff --git a/xen/common/gdbstub.c b/xen/common/gdbstub.c index 48c1b0a41f..5f5beb690a 100644 --- a/xen/common/gdbstub.c +++ b/xen/common/gdbstub.c @@ -376,7 +376,6 @@ process_command(struct cpu_user_regs *regs, struct gdb_context *ctx) break; case 'g': /* Read registers */ gdb_arch_read_reg_array(regs, ctx); - ASSERT(!local_irq_is_enabled()); break; case 'G': /* Write registers */ gdb_arch_write_reg_array(regs, ctx->in_buf + 1, ctx); @@ -395,7 +394,6 @@ process_command(struct cpu_user_regs *regs, struct gdb_context *ctx) return 0; } gdb_cmd_read_mem(addr, length, ctx); - ASSERT(!local_irq_is_enabled()); break; case 'M': /* Write memory */ addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16); @@ -477,7 +475,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie) { int resume = 0; int r; - unsigned flags; + unsigned long flags; if ( gdb_ctx->serhnd < 0 ) { @@ -506,7 +504,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie) if ( !gdb_ctx->connected ) { - printk("GDB connection activated\n"); + printk("GDB connection activated.\n"); gdb_arch_print_state(regs); gdb_ctx->connected = 1; } @@ -522,7 +520,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie) /* Shouldn't really do this, but otherwise we stop for no obvious reason, which is Bad */ - printk("Waiting for GDB to attach to Gdb\n"); + printk("Waiting for GDB to attach...\n"); gdb_arch_enter(regs); gdb_ctx->signum = gdb_arch_signal_num(regs, cookie); @@ -535,9 +533,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie) while ( resume == 0 ) { - ASSERT(!local_irq_is_enabled()); r = receive_command(gdb_ctx); - ASSERT(!local_irq_is_enabled()); if ( r < 0 ) { dbg_printk("GDB disappeared, trying to resume Xen...\n"); @@ -545,9 +541,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie) } else { - ASSERT(!local_irq_is_enabled()); resume = process_command(regs, gdb_ctx); - ASSERT(!local_irq_is_enabled()); } } @@ -561,28 +555,14 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie) return 0; } -/* - * initialization - * XXX TODO - * This should be an explicit call from architecture code. - * initcall is far too late for some early debugging, and only the - * architecture code knows when this call can be made. - */ -static int -initialize_gdb(void) +void +initialise_gdb(void) { - if ( !strcmp(opt_gdb, "none") ) - return 0; gdb_ctx->serhnd = serial_parse_handle(opt_gdb); - if ( gdb_ctx->serhnd == -1 ) - panic("Can't parse %s as GDB serial info.\n", opt_gdb); - - printk("Gdb initialised.\n"); - return 0; + if ( gdb_ctx->serhnd != -1 ) + printk("GDB stub initialised.\n"); } -__initcall(initialize_gdb); - /* * Local variables: * mode: C diff --git a/xen/include/xen/gdbstub.h b/xen/include/xen/gdbstub.h index 9d2e323aed..609831de95 100644 --- a/xen/include/xen/gdbstub.h +++ b/xen/include/xen/gdbstub.h @@ -21,6 +21,8 @@ #ifndef __XEN_GDBSTUB_H__ #define __XEN_GDBSTUB_H__ +#ifdef CRASH_DEBUG + /* value <-> char (de)serialzers for arch specific gdb backends */ char hex2char(unsigned long x); int char2hex(unsigned char c); @@ -84,6 +86,14 @@ void gdb_arch_exit(struct cpu_user_regs *regs); #define SIGALRM 14 #define SIGTERM 15 +void initialise_gdb(void); + +#else + +#define initialise_gdb() ((void)0) + +#endif + #endif /* __XEN_GDBSTUB_H__ */ /* -- 2.30.2